<?php defined('SYSPATH') OR die('No direct access allowed.');

class Catalog_Controller extends Web_Controller {
  
	const ALLOW_PRODUCTION = FALSE;
	public $template = 'kohana/template';
	var $all_count = 0;
 
 	function index(){
 	
		$this->template->content = new View('catalog');
		$this->template->content->error = false;
		$this->selected_page = 'catalog';
		
		$this->template->title = 'Каталог нашей продукции';;

		$table = 'bz_items';
		
		$this->template->content->groups = $this->db->select('*')->from('bz_groups')->
			orderby('gr_sorting')->orderby('gr_title')->get(); 
 
		$this->template->content->items = $this->db->select($table.'.*, bz_types.tp_title, bz_firms.fr_title')->from($table)->
			join('bz_types', 'bz_types.tp_id', $table.'.tp_id', 'left')->
			join('bz_firms', 'bz_firms.fr_id', $table.'.fr_id', 'left')->
			where('bz_items.it_archive = 0')->orderby('bz_types.tp_title')->orderby('bz_firms.fr_title')->get();
		
		$this->template->content->items_ses = $items = $this->session->get('items'); 
		
 	}
	 
}

?>